<template>
  <div>
		<el-dropdown @command="handleCommand">
			<el-text>{{adminStore.admin.name}}</el-text>
			<template #dropdown>
				<el-dropdown-menu>
					<el-dropdown-item command="center">个人主页</el-dropdown-item>
					<el-dropdown-item command="exit">退出登录</el-dropdown-item>
				</el-dropdown-menu>
			</template>
		</el-dropdown>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { get } from '@/axios'
import { userTokenStore, userAdminStore } from '@/stores'
import router from '@/router'  
const adminStore = userAdminStore()
const tokenStore = userTokenStore()

function center () {
	router.push('/center')
}
function exit () {
	router.push('/login')
	tokenStore.setToken(null)
	adminStore.setAdmin(null)
	
}
function handleCommand(arg) {
	eval(arg + '()')
}
</script>

<style scoped lang="scss">
.el-avatar {
	cursor: pointer;
}
</style>